<?r if !@posts.empty? ?>

<?r @posts.each do |post| ?>
<?r created_at = post.created_at.strftime('%Y-%m-%d') ?>

<article>
    <header>
        <h1>
            #{Posts.a(post.title, :view, post.id)}
        </h1>
        <p>
            Created at <time pubdate="pubdate"
            datetime="#{created_at}">#{created_at}</time> and written by
            #{post.user.username}
        </p>
    </header>

    #{RDiscount.new(post.body).to_html}

    <p>
        #{post.comments.length} comment(s)

        <?r if logged_in? ?>
        | #{Posts.a('Edit', :edit, post.id)}
        | #{Posts.a('Delete', :delete, post.id)}
        <?r end ?>
    </p>
</article>

<?r end ?>

#{if @posts.respond_to?(:navigation) and @posts.page_count > 1
  @posts.navigation
end}

<?r else ?>

<p>No posts were found.</p>

<?r end ?>

<?r if logged_in? ?>
<p>#{Posts.a('New Post', :new)}</p>
<?r end ?>
